//
//  TSViewAddToSameViewController.m
//  AppCommonJSCollect
//
//  Created by qian on 2023/10/20.
//  Copyright © 2023 dvlproad. All rights reserved.
//

#import "TSViewAddToSameViewController.h"
#import <Masonry/Masonry.h>
#import "TSSharedNormalViewContainer.h"

@interface TSViewAddToSameViewController ()

@end

@implementation TSViewAddToSameViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1.0]; // #f5f5f5
    [self setupViews];
}

- (void)setupViews {
    UIView *container1 = [[UIView alloc] init];
    container1.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:container1];
    [container1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view).mas_offset(100);
        make.left.mas_equalTo(self.view).mas_offset(20);
        make.centerX.mas_equalTo(self.view);
        make.height.mas_equalTo(200);
    }];
    
    UIView *container2 = [[UIView alloc] init];
    container2.backgroundColor = [UIColor greenColor];
    [self.view addSubview:container2];
    [container2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(container1.mas_bottom).mas_offset(20);
        make.left.mas_equalTo(container1);
        make.centerX.mas_equalTo(container1);
        make.height.mas_equalTo(container1);
    }];
    
    UIView *button = [self getButton];
    [button setFrame:CGRectMake(10, 10, 200, 30)];
//    [button mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(container1).mas_offset(10);
//        make.centerX.mas_equalTo(container1);
//        make.centerX.mas_equalTo(container1);
//        make.height.mas_equalTo(container1);
//    }];
    
    [container2 addSubview:button];
//    [button mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(container2).mas_offset(10);
//        make.centerX.mas_equalTo(container2);
//        make.centerX.mas_equalTo(container2);
//        make.height.mas_equalTo(container2);
//    }];
}


- (UIButton *)getButton {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    [button setBackgroundColor:[UIColor lightGrayColor]];
    [button setTitle:@"我是一个视图实例" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    return button;
}




- (void)addButton:(UIButton *)button toView:(UIView *)container {
//    [button setFrame:CGRectMake(10, 10, 100, 30)];
    [container addSubview:button];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(container).mas_offset(10);
        make.centerX.mas_equalTo(container);
        make.centerY.mas_equalTo(container);
        make.height.mas_equalTo(container);
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
